<html>
<head><meta charset="utf-8"><title>Move towards upstream `macro_rules!` model · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html">Move towards upstream `macro_rules!` model</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="219842603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219842603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219842603">(Dec 14 2020 at 13:46)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> any opinions on <a href="https://github.com/rust-analyzer/ungrammar/pull/14">https://github.com/rust-analyzer/ungrammar/pull/14</a>? I'd like to clean up how we handle macros, and this would be a useful step towards that.</p>



<a name="219842705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219842705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219842705">(Dec 14 2020 at 13:47)</a>:</h4>
<p>Missed that</p>



<a name="219842774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219842774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219842774">(Dec 14 2020 at 13:48)</a>:</h4>
<p>I guess, it makes sense, even if I don't like it from purity perspective :D</p>



<a name="219842791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219842791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219842791">(Dec 14 2020 at 13:48)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> feel free to merge (to also check that you have perms)</p>



<a name="219843005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219843005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219843005">(Dec 14 2020 at 13:50)</a>:</h4>
<p>Thanks! Merging seems to work</p>



<a name="219843243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219843243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219843243">(Dec 14 2020 at 13:51)</a>:</h4>
<p>Hmm, what kind of version bump does this need? Just minor?</p>



<a name="219843316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219843316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219843316">(Dec 14 2020 at 13:52)</a>:</h4>
<p>Ah I'm not a crate owner anyways <a href="https://crates.io/crates/ungrammar">https://crates.io/crates/ungrammar</a></p>



<a name="219843462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219843462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219843462">(Dec 14 2020 at 13:53)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> there's CI job for continious publishing</p>



<a name="219843475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219843475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219843475">(Dec 14 2020 at 13:53)</a>:</h4>
<p>but I prob should add a team</p>



<a name="219843492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219843492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219843492">(Dec 14 2020 at 13:53)</a>:</h4>
<p>minod bump would be ok</p>



<a name="219844773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219844773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219844773">(Dec 14 2020 at 14:04)</a>:</h4>
<blockquote>
<p>thread 'main' panicked at 'not yet implemented: Rep(Seq([Token(Token(14)), Node(Node(39))]))', xtask/src/codegen/gen_syntax.rs:585:13</p>
</blockquote>
<p>seems like <code>xtask codegen</code> dislikes <code>(';' MacroArm)*</code>, although it has no problems with <code>(',' GenericArg)*</code> in <code>GenericArgList</code></p>



<a name="219844998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219844998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219844998">(Dec 14 2020 at 14:06)</a>:</h4>
<p>Yeah, there's a special-casing special-case in there</p>



<a name="219845064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219845064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219845064">(Dec 14 2020 at 14:07)</a>:</h4>
<p><code>lower_comma_list</code></p>



<a name="219845078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219845078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219845078">(Dec 14 2020 at 14:07)</a>:</h4>
<p>ah, yeah</p>



<a name="219845139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219845139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219845139">(Dec 14 2020 at 14:07)</a>:</h4>
<p>although, it <em>should</em> be generic over <code>comma</code> token?</p>



<a name="219845252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219845252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219845252">(Dec 14 2020 at 14:08)</a>:</h4>
<p>Perhaps you need <code>()</code> around the comma list?</p>



<a name="219845409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219845409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219845409">(Dec 14 2020 at 14:09)</a>:</h4>
<p>yeah, looks like it. although macro rules aren't optional.</p>



<a name="219845525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219845525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219845525">(Dec 14 2020 at 14:10)</a>:</h4>
<p>that needs to be a validation error I think</p>



<a name="219873211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219873211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219873211">(Dec 14 2020 at 17:21)</a>:</h4>
<p>Hmm, this generates the wrong API for <code>MacroArm</code></p>
<div class="codehilite"><pre><span></span><code>MacroArm =
  TokenTree &#39;=&gt;&#39; TokenTree
</code></pre></div>
<p>The resulting <code>MacroArm</code> type only has a single <code>fn token_tree(&amp;self) -&gt; Option&lt;TokenTree&gt;</code></p>



<a name="219873346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219873346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219873346">(Dec 14 2020 at 17:22)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/ungrammar/blob/d41a4110554501314bdfcabe5b41971abda99397/rust.ungram#L382-L389">https://github.com/rust-analyzer/ungrammar/blob/d41a4110554501314bdfcabe5b41971abda99397/rust.ungram#L382-L389</a></p>



<a name="219873382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219873382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219873382">(Dec 14 2020 at 17:22)</a>:</h4>
<p>I think you need</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">MacroArm</span><span class="w"> </span><span class="o">=</span><span class="w"></span>
<span class="w">  </span><span class="n">pattern</span>:<span class="nc">TokenTree</span><span class="w"> </span><span class="o">'=&gt;'</span><span class="w"> </span><span class="n">template</span>:<span class="nc">TokenTree</span><span class="w"></span>
</code></pre></div>



<a name="219873400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219873400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219873400">(Dec 14 2020 at 17:22)</a>:</h4>
<p>aah, nice</p>



<a name="219878847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219878847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219878847">(Dec 14 2020 at 18:03)</a>:</h4>
<p>I think I'll roll back the addition of <code>MacroArm</code>, it requires too many changes in mbe</p>



<a name="219889644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Move%20towards%20upstream%20%60macro_rules%21%60%20model/near/219889644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Move.20towards.20upstream.20.60macro_rules!.60.20model.html#219889644">(Dec 14 2020 at 19:23)</a>:</h4>
<p>yeah...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>